import { GCellRenderer } from "../../../../com/mui/controls/GCellRenderer";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { BaseItem } from "../common/BaseItem";
import { ItemData } from "../../resource/info/ItemData";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
//class TreasureItemRenderer
    
    export  class TreasureItemRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            addEventListener(flash.events.MouseEvent.CLICK, this.onItemMouseClickHandler);
            return;
        }

        protected /* override */ configUI(): void
        {
            var loc1=GlobalClass.getBitmap(ImagesConst.PackItemBg);
            addChild(loc1);
            this._item = new BaseItem();
            this._item.setSize(32, 32);
            this._item.move(2, 2);
            this._item.isDragAble = false;
            this._item.isDropAble = false;
            this._item.isShowLock = true;
            addChild(this._item);
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            if (arg1 == null) 
            {
                this._itemData = null;
                this._item.itemData = null;
            }
            else 
            {
                this._itemData = arg1 as ItemData;
                this._item.itemData = this._itemData;
            }
            return;
        }

        /* internal  */onItemMouseClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._itemData == null) 
            {
                return;
            }
            var loc1=new Map<any, any> /* flash.utils.Dictionary */();
            loc1[this._itemData.uid] = this._itemData.itemAmount;
            if (data != null) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.TreasureMoveToBag, loc1));
            }
            return;
        }

        /* internal */ /* var */_item: BaseItem;

        /* internal */ /* var */_itemData: ItemData;
    }
